#pragma once

#include <jni.h>
#include <string.h>
#include <stdio.h>
#include <string>

#include "JniDefine.h"
#include "JniHelper.h"

class JniObject
{
public:
    JniObject();
    virtual ~JniObject();
    void init(JNIEnv* env, jobject thiz);

    void createAndBindJavaObject(JNIEnv* env);

    JniObject* getObjectFromJava(jobject thiz);
    static JniObject* getObjectFromJava(JNIEnv* env, jobject thiz);

    DECLARE_CLASS_NAME("kaz.JniObject");

    BEGIN_NATIVE_METHODS()
        ON_NATIVE_METHOD("create_and_bind_object", "(Ljava/lang/String;)V", _create_and_bind_object)
        ON_NATIVE_METHOD("bind_object", "(J)V", _bind_object)
    END_NATIVE_METHODS()

    // EMPTY_JAVA_METHODS();
    virtual void initJavaMethods(JNIEnv* env) {}

    static char* alterClassName(char* className);
    static std::string getAlteredClassName();
protected:
    JNIEnv*     mEnv;
    jobject     mThiz;

private:
    jmethodID   mCreateAndBind;
    static void _native_test(JNIEnv* env, jobject thiz);
    static void _create_and_bind_object(JNIEnv* env, jobject thiz, jstring clazzname);
    static void _bind_object(JNIEnv* env, jobject thiz, jlong oo);
};


